home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cli / rebootscript.lha / Rebootscript / WriteScript.S < prev   
Text File  |  2000-08-24  |  3KB  |  131 lines

  1. ;******************************************************************************
  2. ; Write path, and reboot da machine.
  3. ; (Compiled with AsmPro V1.16d)
  4. ;
  5. ; Use this file f.ex: WriteScript dh0:Games/A/Arkanoid.bat
  6. ;
  7. ; (c) Per Johansson aka Olle^Omen / Latex, Craze, Planet Jazz, Massive
  8. ;
  9. ;         omen@telia.com        http://go.to/olle    (2000-08-23)
  10. ;******************************************************************************
  11.  
  12.         incdir    Includes:
  13.         include Exec/Exec.I
  14.         include Exec/Exec_Lib.I
  15.  
  16.         include Exec/types.i
  17.         include Exec/libraries.i
  18.         
  19.         include Dos/Dos.I
  20.         include Dos/Dos_Lib.I
  21.  
  22.  
  23. Start        lea.l    Pathbuffer,a1
  24.         moveq.l    #0,d0
  25.         move.l    #256-1,d7
  26. .l        tst.b    (a0)
  27.         beq.w    .q
  28.         move.b    (a0)+,(a1)+
  29.         add.l    #1,d0
  30.         dbra    d7,.l
  31. .q        tst.b    d0
  32.         beq.w    .quit
  33.         subq.l    #1,d0
  34.         move.l    d0,PathLength
  35.         bsr.w    Writepath
  36. .quit        rts
  37.  
  38. Writepath    move.l    #Savename,d1        ; Delete previous
  39.         bsr.w    _Dos_Delete        ; if needed.
  40.  
  41.         move.l    #Savename,d1
  42.         bsr.w    _Dos_Openfile
  43.  
  44.         move.l    #Pathbuffer,d2        ; Write submitted path
  45.         move.l    PathLength(pc),d3    ; to tempfile.
  46.         bsr.w    _Dos_Write
  47.  
  48.         bsr.w    _Dos_Closefile
  49.  
  50.         move.l    #128,d1            ; Wait for hd, before reset
  51.         bsr.w    _Dos_Delay
  52.  
  53.         bsr.w    Reset            ; Reset
  54.  
  55.         rts
  56.  
  57.  
  58. ; HWREF-Reset
  59.  
  60. Reset        move.l    $4.w,a6
  61.         cmp.w    #36,LIB_VERSION(a6)
  62.         blt    .oldexec
  63.         jmp    -726(a6)
  64. .oldexec    lea.l    .goaway(pc),a5
  65.         jsr    _LVOSupervisor(a6)
  66.         rts
  67.         even
  68. .goaway        lea.l    MAGIC_ROMEND,a0
  69.         sub.l    MAGIC_SIZEOFFSET(a0),a0
  70.         move.l    4(a0),a0
  71.         subq.l    #2,a0
  72.         reset
  73.         jmp    (a0)
  74.  
  75.  
  76.         Xdef    _Dos_Openfile
  77.         Xdef    _Dos_Closefile
  78.         Xdef    _Dos_Read
  79.         Xdef    _Dos_Write
  80.         Xdef    _Dos_Delete
  81.         Xdef    _Dos_Execute
  82.         Xdef    _Dos_Getsize
  83.         inclink    .asm:lo/dos.lnk
  84.  
  85.  
  86. ;+----------------------------------------------------------------------------+
  87. ;|         APrintf - Print's the string in a0 to stdout (could be pipe'd)       |
  88. ;|                                          |
  89. ;| In: A0 = String to print!                              |
  90. ;|                                          |
  91. ;| Thrashes no registers                              |
  92. ;+----------------------------------------------------------------------------+
  93.  
  94. APrintf        movem.l    d0-d7/a0-a6,-(sp)
  95.         move.l    a0,-(Sp)        ; Save Textpointer
  96.         moveq.l    #0,d0            ; Any version.
  97.         lea.l    .PDosName(Pc),a1
  98.         CALLEXEC OpenLibrary
  99.         move.l     d0,.PDosBase
  100.         beq.w    .Fail
  101.         move.l     (Sp)+,a0        ; Restore Textpointer
  102.         move.l     a0,a1
  103.         moveq.l     #0,d3            ; Calculate Size
  104. .Srch        tst.b     (a0)+
  105.         beq.w     .Fnd
  106.         addq.l     #1,d3
  107.         bra.w     .Srch
  108. .Fnd        move.l   .PDosBase(Pc),a6
  109.         jsr     _LVOOutput(a6)        ; Get Stdout
  110.         move.l     d0,d1            ; File (Stdout)
  111.         move.l     a1,d2            ; Text pointer
  112.         jsr     _LVOWrite(a6)        ; (File=D1,Data=D2,Length=D3)
  113.         move.l     .PDosBase(Pc),a1
  114.         CALLEXEC CloseLibrary
  115. .Fail        movem.l    (sp)+,d0-d7/a0-a6
  116.         rts
  117.  
  118. .PDosBase    dc.l    0
  119. .PDosName    dc.b    'dos.library',0
  120.         even
  121. Savename    dc.b    's:rebootscript.bat',0    ; Filename to read.
  122.         even
  123.  
  124. MAGIC_ROMEND    =    $01000000
  125. MAGIC_SIZEOFFSET=    -$14
  126.  
  127. PathLength    dc.l    0
  128.         section    buffers,bss_p
  129.  
  130. Pathbuffer    ds.b    256
  131.